﻿using APP.HELPER.Data.Helper;
using DevExpress.XtraEditors;
using Extra.ERP;
using HRM.CORE.CLASS;
using System; using Extra.ERP;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;

namespace HRM.CORE
{
    public class HRM_CONTRACT
    {
        private string m_Address;
        private string m_Allowance;
        private decimal m_BasicSalary;
        private string m_Company;
        private decimal m_Compensation;
        private string m_ContractCode;
        private string m_ContractTime;
        private int m_ContractType;
        private string m_CreatePlace;
        private string m_Description;
        private string m_EmployeeCode;
        private DateTime m_FromDate;
        private string m_Insurance;
        private bool m_IsCurrent;
        private string m_PayDate;
        private string m_PayForm;
        private DateTime m_SignDate;
        private string m_Signer;
        private string m_SignerNationality;
        private string m_SignerPosition;
        private string m_Subject;
        private string m_Tel;
        private DateTime m_ToDate;
        private string m_WorkTime;

        public HRM_CONTRACT()
        {
            this.m_ContractCode = "";
            this.m_EmployeeCode = "";
            this.m_ContractType = 0;
            this.m_ContractTime = "";
            this.m_SignDate = DateTime.Now;
            this.m_FromDate = DateTime.Now;
            this.m_ToDate = DateTime.Now;
            this.m_BasicSalary = 0M;
            this.m_PayForm = "";
            this.m_PayDate = "";
            this.m_Allowance = "";
            this.m_Insurance = "";
            this.m_WorkTime = "";
            this.m_Compensation = 0M;
            this.m_Signer = "";
            this.m_SignerPosition = "";
            this.m_SignerNationality = "";
            this.m_Company = "";
            this.m_Address = "";
            this.m_Tel = "";
            this.m_CreatePlace = "";
            this.m_Subject = "";
            this.m_Description = "";
            this.m_IsCurrent = true;
        }

        public HRM_CONTRACT(string ContractCode, string EmployeeCode, int ContractType, string ContractTime, DateTime SignDate, DateTime FromDate, DateTime ToDate, decimal BasicSalary, string PayForm, string PayDate, string Allowance, string Insurance, string WorkTime, decimal Compensation, string Signer, string SignerPosition, string SignerNationality, string Company, string Address, string Tel, string CreatePlace, string Subject, string Description, bool IsCurrent)
        {
            this.m_ContractCode = ContractCode;
            this.m_EmployeeCode = EmployeeCode;
            this.m_ContractType = ContractType;
            this.m_ContractTime = ContractTime;
            this.m_SignDate = SignDate;
            this.m_FromDate = FromDate;
            this.m_ToDate = ToDate;
            this.m_BasicSalary = BasicSalary;
            this.m_PayForm = PayForm;
            this.m_PayDate = PayDate;
            this.m_Allowance = Allowance;
            this.m_Insurance = Insurance;
            this.m_WorkTime = WorkTime;
            this.m_Compensation = Compensation;
            this.m_Signer = Signer;
            this.m_SignerPosition = SignerPosition;
            this.m_SignerNationality = SignerNationality;
            this.m_Company = Company;
            this.m_Address = Address;
            this.m_Tel = Tel;
            this.m_CreatePlace = CreatePlace;
            this.m_Subject = Subject;
            this.m_Description = Description;
            this.m_IsCurrent = IsCurrent;
        }

        public void AddComboEdit(ComboBoxEdit combo)
        {
            DataTable list = new DataTable();
            list = this.GetList(MyLogin.Level, MyLogin.Code);
            foreach (DataRow row in list.Rows)
            {
                combo.Properties.Items.Add(row["ContractCode"]);
            }
        }

        public void AddComboEdit(ComboBoxEdit combo, string EmployeeCode)
        {
            DataTable listByEmployee = new DataTable();
            listByEmployee = this.GetListByEmployee(EmployeeCode);
            foreach (DataRow row in listByEmployee.Rows)
            {
                combo.Properties.Items.Add(row["ContractCode"]);
            }
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@ContractCode" };
            object[] myValues = new object[] { this.m_ContractCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_CONTRACT_Delete", myParams, myValues);
        }

        public string Delete(string ContractCode)
        {
            string[] myParams = new string[] { "@ContractCode" };
            object[] myValues = new object[] { ContractCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_CONTRACT_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string ContractCode)
        {
            string[] myParams = new string[] { "@ContractCode" };
            object[] myValues = new object[] { ContractCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_CONTRACT_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string ContractCode)
        {
            string[] myParams = new string[] { "@ContractCode" };
            object[] myValues = new object[] { ContractCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_CONTRACT_Delete", myParams, myValues);
        }

        public bool Exist(string ContractCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@ContractCode" };
            object[] myValues = new object[] { ContractCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_CONTRACT_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public bool ExistByEmployee(string EmployeeCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_CONTRACT_GetByEmployee", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string ContractCode)
        {
            string str = "";
            string[] myParams = new string[] { "@ContractCode" };
            object[] myValues = new object[] { ContractCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_CONTRACT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ContractCode = Convert.ToString(reader["ContractCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_ContractType = Convert.ToInt32(reader["ContractType"]);
                    this.m_ContractTime = Convert.ToString(reader["ContractTime"]);
                    this.m_SignDate = Convert.ToDateTime(reader["SignDate"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_BasicSalary = Convert.ToDecimal(reader["BasicSalary"]);
                    this.m_PayForm = Convert.ToString(reader["PayForm"]);
                    this.m_PayDate = Convert.ToString(reader["PayDate"]);
                    this.m_Allowance = Convert.ToString(reader["Allowance"]);
                    this.m_Insurance = Convert.ToString(reader["Insurance"]);
                    this.m_WorkTime = Convert.ToString(reader["WorkTime"]);
                    this.m_Compensation = Convert.ToDecimal(reader["Compensation"]);
                    this.m_Signer = Convert.ToString(reader["Signer"]);
                    this.m_SignerPosition = Convert.ToString(reader["SignerPosition"]);
                    this.m_SignerNationality = Convert.ToString(reader["SignerNationality"]);
                    this.m_Company = Convert.ToString(reader["Company"]);
                    this.m_Address = Convert.ToString(reader["Address"]);
                    this.m_Tel = Convert.ToString(reader["Tel"]);
                    this.m_CreatePlace = Convert.ToString(reader["CreatePlace"]);
                    this.m_Subject = Convert.ToString(reader["Subject"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_IsCurrent = Convert.ToBoolean(reader["IsCurrent"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetCurrentList(int Level, string Code)
        {
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { Level, Code };
            SqlHelper helper = new SqlHelper {
                CommandType = CommandType.Text
            };
            return helper.ExecuteDataTable("Select hc.*, he.FirstName, he.LastName, hb.BranchName, hd.DepartmentName,hg.GroupName \r\nFrom [HRM_CONTRACT] hc \r\ninner join [HRM_EMPLOYEE] he on hc.EmployeeCode=he.EmployeeCode\r\ninner join [HRM_BRANCH] hb on he.BranchCode=hb.BranchCode\r\nleft join [HRM_DEPARTMENT] hd on he.DepartmentCode=hd.DepartmentCode\r\nLEFT JOIN [HRM_GROUP] hg ON he.GroupCode=hg.GroupCode\r\n\tWhere getdate()<=hc.ToDate\r\n\t\t--and IsCurrent=1\r\n\t\tAND (CASE @Level\r\n\t\t\twhen 0 then @Code\r\n\t\t\twhen 1 then he.BranchCode\r\n\t\t\twhen 2 then he.DepartmentCode\r\n\t\t\twhen 3 then he.GroupCode\r\n\t\t\tEND=@Code)", myParams, myValues);
        }

        public DataTable GetList(int Level, string Code)
        {
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { Level, Code };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_CONTRACT_GetList", myParams, myValues);
        }

        public DataTable GetListByContract(string ContractCode, string EmployeeCode)
        {
            string[] myParams = new string[] { "@ContractCode", "@EmployeeCode" };
            object[] myValues = new object[] { ContractCode, EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_CONTRACT_GetByContract", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_CONTRACT_GetByEmployee", myParams, myValues);
        }

        public DataTable GetListExpiration(int Level, string Code)
        {
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { Level, Code };
            SqlHelper helper = new SqlHelper {
                CommandType = CommandType.Text
            };
            return helper.ExecuteDataTable("Select hc.*, he.FirstName, he.LastName ,hb.BranchName,hd.DepartmentName,hg.GroupName\r\nFrom [HRM_CONTRACT] hc \r\ninner join [HRM_EMPLOYEE] he on hc.EmployeeCode=he.EmployeeCode\r\ninner join [HRM_BRANCH] hb on he.BranchCode=hb.BranchCode\r\nleft join [HRM_DEPARTMENT] hd on he.DepartmentCode=hd.DepartmentCode\r\nLEFT JOIN [HRM_GROUP] hg ON he.GroupCode=hg.GroupCode\r\n\tWhere hc.ToDate<getdate()\r\n\tAND (CASE @Level\r\n\t\t\twhen 0 then @Code\r\n\t\t\twhen 1 then he.BranchCode\r\n\t\t\twhen 2 then he.DepartmentCode\r\n\t\t\twhen 3 then he.GroupCode\r\n\t\t\tEND=@Code)", myParams, myValues);
        }

        public DataTable GetListJustExpiration(int Level, string Code)
        {
            clsContractOption option = new clsContractOption();
            string[] myParams = new string[] { "@Level", "@Code", "@NumberDayWarning" };
            object[] myValues = new object[] { Level, Code, option.NumberDayWarning };
            SqlHelper helper = new SqlHelper {
                CommandType = CommandType.Text
            };
            return helper.ExecuteDataTable("Select hc.*, he.FirstName, he.LastName, hb.BranchName, hd.DepartmentName,hg.GroupName \r\nFrom [HRM_CONTRACT] hc \r\ninner join [HRM_EMPLOYEE] he on hc.EmployeeCode=he.EmployeeCode\r\ninner join [HRM_BRANCH] hb on he.BranchCode=hb.BranchCode\r\nleft join [HRM_DEPARTMENT] hd on he.DepartmentCode=hd.DepartmentCode\r\nLEFT JOIN [HRM_GROUP] hg ON he.GroupCode=hg.GroupCode\r\n\tWhere getdate()>=dateadd(d,-(@NumberDayWarning),hc.ToDate)\r\n        and getdate()<=hc.ToDate\r\n\t\t--and IsCurrent=1\r\n\t\tAND (CASE @Level\r\n\t\t\twhen 0 then @Code\r\n\t\t\twhen 1 then he.BranchCode\r\n\t\t\twhen 2 then he.DepartmentCode\r\n\t\t\twhen 3 then he.GroupCode\r\n\t\t\tEND=@Code)", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                this.m_ContractCode, this.m_EmployeeCode, this.m_ContractType, this.m_ContractTime, this.m_SignDate, this.m_FromDate, this.m_ToDate, this.m_BasicSalary, this.m_PayForm, this.m_PayDate, this.m_Allowance, this.m_Insurance, this.m_WorkTime, this.m_Compensation, this.m_Signer, this.m_SignerPosition, 
                this.m_SignerNationality, this.m_Company, this.m_Address, this.m_Tel, this.m_CreatePlace, this.m_Subject, this.m_Description, this.m_IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_CONTRACT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                this.m_ContractCode, this.m_EmployeeCode, this.m_ContractType, this.m_ContractTime, this.m_SignDate, this.m_FromDate, this.m_ToDate, this.m_BasicSalary, this.m_PayForm, this.m_PayDate, this.m_Allowance, this.m_Insurance, this.m_WorkTime, this.m_Compensation, this.m_Signer, this.m_SignerPosition, 
                this.m_SignerNationality, this.m_Company, this.m_Address, this.m_Tel, this.m_CreatePlace, this.m_Subject, this.m_Description, this.m_IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_CONTRACT_Insert", myParams, myValues);
        }

        public string Insert(string ContractCode, string EmployeeCode, int ContractType, string ContractTime, DateTime SignDate, DateTime FromDate, DateTime ToDate, decimal BasicSalary, string PayForm, string PayDate, string Allowance, string Insurance, string WorkTime, decimal Compensation, string Signer, string SignerPosition, string SignerNationality, string Company, string Address, string Tel, string CreatePlace, string Subject, string Description, bool IsCurrent)
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                ContractCode, EmployeeCode, ContractType, ContractTime, SignDate, FromDate, ToDate, BasicSalary, PayForm, PayDate, Allowance, Insurance, WorkTime, Compensation, Signer, SignerPosition, 
                SignerNationality, Company, Address, Tel, CreatePlace, Subject, Description, IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_CONTRACT_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, string ContractCode, string EmployeeCode, int ContractType, string ContractTime, DateTime SignDate, DateTime FromDate, DateTime ToDate, decimal BasicSalary, string PayForm, string PayDate, string Allowance, string Insurance, string WorkTime, decimal Compensation, string Signer, string SignerPosition, string SignerNationality, string Company, string Address, string Tel, string CreatePlace, string Subject, string Description, bool IsCurrent)
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                ContractCode, EmployeeCode, ContractType, ContractTime, SignDate, FromDate, ToDate, BasicSalary, PayForm, PayDate, Allowance, Insurance, WorkTime, Compensation, Signer, SignerPosition, 
                SignerNationality, Company, Address, Tel, CreatePlace, Subject, Description, IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_CONTRACT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, string ContractCode, string EmployeeCode, int ContractType, string ContractTime, DateTime SignDate, DateTime FromDate, DateTime ToDate, decimal BasicSalary, string PayForm, string PayDate, string Allowance, string Insurance, string WorkTime, decimal Compensation, string Signer, string SignerPosition, string SignerNationality, string Company, string Address, string Tel, string CreatePlace, string Subject, string Description, bool IsCurrent)
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                ContractCode, EmployeeCode, ContractType, ContractTime, SignDate, FromDate, ToDate, BasicSalary, PayForm, PayDate, Allowance, Insurance, WorkTime, Compensation, Signer, SignerPosition, 
                SignerNationality, Company, Address, Tel, CreatePlace, Subject, Description, IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_CONTRACT_Insert", myParams, myValues);
        }

        private bool IsNumeric(object expression)
        {
            double num;
            return double.TryParse(Convert.ToString(expression), NumberStyles.Any, (IFormatProvider) NumberFormatInfo.InvariantInfo, out num);
        }

        public string NewID()
        {
            clsDocumentNumberOption option = new clsDocumentNumberOption("ContractCode", "HDLD/", "/" + DateTime.Now.Year);
            return option.GenCode("HRM_CONTRACT", "ContractCode");
        }

        public string Update()
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                this.m_ContractCode, this.m_EmployeeCode, this.m_ContractType, this.m_ContractTime, this.m_SignDate, this.m_FromDate, this.m_ToDate, this.m_BasicSalary, this.m_PayForm, this.m_PayDate, this.m_Allowance, this.m_Insurance, this.m_WorkTime, this.m_Compensation, this.m_Signer, this.m_SignerPosition, 
                this.m_SignerNationality, this.m_Company, this.m_Address, this.m_Tel, this.m_CreatePlace, this.m_Subject, this.m_Description, this.m_IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_CONTRACT_Update", myParams, myValues);
        }

        public string Update(string ContractCode, string EmployeeCode, int ContractType, string ContractTime, DateTime SignDate, DateTime FromDate, DateTime ToDate, decimal BasicSalary, string PayForm, string PayDate, string Allowance, string Insurance, string WorkTime, decimal Compensation, string Signer, string SignerPosition, string SignerNationality, string Company, string Address, string Tel, string CreatePlace, string Subject, string Description, bool IsCurrent)
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                ContractCode, EmployeeCode, ContractType, ContractTime, SignDate, FromDate, ToDate, BasicSalary, PayForm, PayDate, Allowance, Insurance, WorkTime, Compensation, Signer, SignerPosition, 
                SignerNationality, Company, Address, Tel, CreatePlace, Subject, Description, IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_CONTRACT_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string ContractCode, string EmployeeCode, int ContractType, string ContractTime, DateTime SignDate, DateTime FromDate, DateTime ToDate, decimal BasicSalary, string PayForm, string PayDate, string Allowance, string Insurance, string WorkTime, decimal Compensation, string Signer, string SignerPosition, string SignerNationality, string Company, string Address, string Tel, string CreatePlace, string Subject, string Description, bool IsCurrent)
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                ContractCode, EmployeeCode, ContractType, ContractTime, SignDate, FromDate, ToDate, BasicSalary, PayForm, PayDate, Allowance, Insurance, WorkTime, Compensation, Signer, SignerPosition, 
                SignerNationality, Company, Address, Tel, CreatePlace, Subject, Description, IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_CONTRACT_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string ContractCode, string EmployeeCode, int ContractType, string ContractTime, DateTime SignDate, DateTime FromDate, DateTime ToDate, decimal BasicSalary, string PayForm, string PayDate, string Allowance, string Insurance, string WorkTime, decimal Compensation, string Signer, string SignerPosition, string SignerNationality, string Company, string Address, string Tel, string CreatePlace, string Subject, string Description, bool IsCurrent)
        {
            string[] myParams = new string[] { 
                "@ContractCode", "@EmployeeCode", "@ContractType", "@ContractTime", "@SignDate", "@FromDate", "@ToDate", "@BasicSalary", "@PayForm", "@PayDate", "@Allowance", "@Insurance", "@WorkTime", "@Compensation", "@Signer", "@SignerPosition", 
                "@SignerNationality", "@Company", "@Address", "@Tel", "@CreatePlace", "@Subject", "@Description", "@IsCurrent"
             };
            object[] myValues = new object[] { 
                ContractCode, EmployeeCode, ContractType, ContractTime, SignDate, FromDate, ToDate, BasicSalary, PayForm, PayDate, Allowance, Insurance, WorkTime, Compensation, Signer, SignerPosition, 
                SignerNationality, Company, Address, Tel, CreatePlace, Subject, Description, IsCurrent
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_CONTRACT_Update", myParams, myValues);
        }

        [Category("Column"), DisplayName("Address")]
        public string Address
        {
            get
            {
                return this.m_Address;
            }
            set
            {
                this.m_Address = value;
            }
        }

        [Category("Column"), DisplayName("Allowance")]
        public string Allowance
        {
            get
            {
                return this.m_Allowance;
            }
            set
            {
                this.m_Allowance = value;
            }
        }

        [Category("Column"), DisplayName("BasicSalary")]
        public decimal BasicSalary
        {
            get
            {
                return this.m_BasicSalary;
            }
            set
            {
                this.m_BasicSalary = value;
            }
        }

        [Category("Column"), DisplayName("Company")]
        public string Company
        {
            get
            {
                return this.m_Company;
            }
            set
            {
                this.m_Company = value;
            }
        }

        [DisplayName("Compensation"), Category("Column")]
        public decimal Compensation
        {
            get
            {
                return this.m_Compensation;
            }
            set
            {
                this.m_Compensation = value;
            }
        }

        [Category("Primary Key"), DisplayName("ContractCode")]
        public string ContractCode
        {
            get
            {
                return this.m_ContractCode;
            }
            set
            {
                this.m_ContractCode = value;
            }
        }

        [Category("Column"), DisplayName("ContractTime")]
        public string ContractTime
        {
            get
            {
                return this.m_ContractTime;
            }
            set
            {
                this.m_ContractTime = value;
            }
        }

        [DisplayName("ContractType"), Category("Column")]
        public int ContractType
        {
            get
            {
                return this.m_ContractType;
            }
            set
            {
                this.m_ContractType = value;
            }
        }

        [Category("Column"), DisplayName("CreatePlace")]
        public string CreatePlace
        {
            get
            {
                return this.m_CreatePlace;
            }
            set
            {
                this.m_CreatePlace = value;
            }
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [Category("Primary Key"), DisplayName("EmployeeCode")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("FromDate"), Category("Column")]
        public DateTime FromDate
        {
            get
            {
                return this.m_FromDate;
            }
            set
            {
                this.m_FromDate = value;
            }
        }

        [Category("Column"), DisplayName("Insurance")]
        public string Insurance
        {
            get
            {
                return this.m_Insurance;
            }
            set
            {
                this.m_Insurance = value;
            }
        }

        [Category("Column"), DisplayName("IsCurrent")]
        public bool IsCurrent
        {
            get
            {
                return this.m_IsCurrent;
            }
            set
            {
                this.m_IsCurrent = value;
            }
        }

        [DisplayName("PayDate"), Category("Column")]
        public string PayDate
        {
            get
            {
                return this.m_PayDate;
            }
            set
            {
                this.m_PayDate = value;
            }
        }

        [DisplayName("PayForm"), Category("Column")]
        public string PayForm
        {
            get
            {
                return this.m_PayForm;
            }
            set
            {
                this.m_PayForm = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_CONTRACT";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [DisplayName("SignDate"), Category("Column")]
        public DateTime SignDate
        {
            get
            {
                return this.m_SignDate;
            }
            set
            {
                this.m_SignDate = value;
            }
        }

        [DisplayName("Signer"), Category("Column")]
        public string Signer
        {
            get
            {
                return this.m_Signer;
            }
            set
            {
                this.m_Signer = value;
            }
        }

        [Category("Column"), DisplayName("SignerNationality")]
        public string SignerNationality
        {
            get
            {
                return this.m_SignerNationality;
            }
            set
            {
                this.m_SignerNationality = value;
            }
        }

        [Category("Column"), DisplayName("SignerPosition")]
        public string SignerPosition
        {
            get
            {
                return this.m_SignerPosition;
            }
            set
            {
                this.m_SignerPosition = value;
            }
        }

        [Category("Column"), DisplayName("Subject")]
        public string Subject
        {
            get
            {
                return this.m_Subject;
            }
            set
            {
                this.m_Subject = value;
            }
        }

        [DisplayName("Tel"), Category("Column")]
        public string Tel
        {
            get
            {
                return this.m_Tel;
            }
            set
            {
                this.m_Tel = value;
            }
        }

        [Category("Column"), DisplayName("ToDate")]
        public DateTime ToDate
        {
            get
            {
                return this.m_ToDate;
            }
            set
            {
                this.m_ToDate = value;
            }
        }

        [Category("Column"), DisplayName("WorkTime")]
        public string WorkTime
        {
            get
            {
                return this.m_WorkTime;
            }
            set
            {
                this.m_WorkTime = value;
            }
        }
    }
}

